#!/usr/bin/env bash

function execute {
    PARAMETERS=$*
    OUTPUT=$(echo $PARAMETERS | sed 's/ /_/g').out
    java -jar $JAR $PARAMETERS > $OUTPUT
}

if [ $# != 1 ]; then
    echo "Error! Usage <a file with all combinations of input parameters in each line>"
	exit 1
fi

FILE=$1
JAR=proj2.jar

if [ ! -e $JAR ]; then
    echo "Error! JAR not found: " $JAR
    exit 1
fi


cat $FILE | \
while read line; do
    execute $line
done
